<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        
        .wrap {
            position: relative;
            width: 700px;
            height: 500px;
            margin: 50px auto;
        }
        
        .wrap ul li img {
            position: absolute;
            width: 100%;
            height: 100%;
            opacity: 0;
            transition: all 0.9s;
        }
        
        .left,
        .right {
            position: absolute;
            text-align: center;
            line-height: 70px;
            top: 235px;
            width: 70px;
            height: 70px;
            background-color: white;
            cursor: pointer;
            z-index: 10;
        }
        
        .right {
            right: 0;
        }
        
        .list {
            width: 80px;
            height: 10px;
            position: absolute;
            right: 0;
            bottom: 10px;
            z-index: 100;
        }
        
        .list .point {
            width: 10px;
            height: 10px;
            float: left;
            border-radius: 100%;
            border: solid 1px #ccc;
            background-color: white;
            margin-right: 10px;
            cursor: pointer;
        }
        
        .wrap ul .show img {
            opacity: 1;
            display: block;
            z-index: 10;
        }
        
        .list .show {
            background-color: green;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <ul>
            <li class="show"><img src="./picture/1.jpg" alt=""></li>
            <li><img src="./picture/2.jpg" alt=""></li>
            <li><img src="./picture/3.jpg" alt=""></li>

        </ul>
        <div class="left">《</div>
        <div class="right">》</div>

        <div class="list">
            <div class="point show" data-index="0"></div>
            <div class="point " data-index="1"></div>
            <div class="point" data-index="2"></div>
        </div>
    </div>
    <script>
        let left = document.getElementsByClassName('left')[0];
        let right = document.getElementsByClassName('right')[0];
        let pic = document.getElementsByTagName('li');
        let point = document.getElementsByClassName('point');
        console.log(right);

        let index = 0;

        function clear() {
            for (let i = 0; i < pic.length; i++) {
                pic[i].className = ''
                point[i].className = 'point'
            }
        }

        function goindex() {
            pic[index].className = 'show'
            point[index].className = 'point show'
        }

        function goright() {
            if (index >= 2) {
                index = 0
            } else {
                index++;
            }
            clear();
            goindex();
        }

        right.addEventListener('click', goright);

        left.addEventListener('click', function() {
            if (index <= 0) {
                index = 2
            } else {
                index--;
            }
            clear();
            goindex();
        })
        for (let i = 0; i < point.length; i++) {
            point[i].addEventListener('click', function() {
                let pointkey = this.getAttribute('data-index');
                index = pointkey;
                clear();
                goindex();
            })
        }

        setInterval(() => {
            goright()
        }, 1000)
    </script>

</body>

</html>